<template>
	<view class="index">
		<view class="tabs">
			<liuyuno-tabs :tabData="tabs" :defaultIndex="defaultIndex" @tabClick='tabClick' />
		</view>
		<block v-if="defaultIndex === 0" v-for="(item, index) in jokeList" :key="index">
			<view class="card">
				<view class="car-title-view" >
						<view class="width100 row-center">
							{{item.name}}
						</view>
						<view class="width100" style="text-indent:2em;">
							{{item.context}}
						</view>
				</view>
			</view>
		</block>
		<block v-if="defaultIndex === 1" v-for="(item, index) in loveList" :key="index">
			<view class="card">
				<view class="car-title-view" >
						<view class="width100 row-center">
							{{item.name}}
						</view>
						<view class="width100" style="text-indent:2em;">
							{{item.context}}
						</view>
				</view>
			</view>
		</block>
	</view>
</template>
<script>
	import wybTable from '@/components/wyb-table/wyb-table.vue'
	import liuyunoTabs from '@/components/liuyuno-tabs/liuyuno-tabs.vue';
	import util, { parGetData, parSetData, checklogin } from '../../common/util';
	export default {
		data() {
			return {
				jokeList: [],
				loveList: [],
				tabs: ['应景笑话', '情话'],
				defaultIndex: 0
			};
		},
		components: {
			wybTable,
			liuyunoTabs
		},
		created() {
			this.getJoke();
			this.getLove();
		},
		methods: {	
			tabClick(index) {
				this.defaultIndex = index;
			},
			getJoke() {
				var self = this;
				uni.request({
					url: util.apiurl + 'generator/joke/list',
					method: 'POST',
					dataType: 'json',
					data: {
					},
					success: function(ret) {
						if (ret.data.code == 200) {
							self.jokeList = ret.data.data.list;
						}
					},
					fail: res => {
						uni.showToast({
							title: '请求数据失败请重试1',
							duration: 2000,
							icon: 'none'
						});
					},
					complete: function() {
					}
				});
			},
			getLove() {
				var self = this;
				uni.request({
					url: util.apiurl + 'generator/love/list',
					method: 'POST',
					dataType: 'json',
					data: {
					},
					success: function(ret) {
						if (ret.data.code == 200) {
							self.loveList = ret.data.data.list;
						}
					},
					fail: res => {
						uni.showToast({
							title: '请求数据失败请重试1',
							duration: 2000,
							icon: 'none'
						});
					},
					complete: function() {
					}
				});
			}
		}
	};
</script>

<style>
	.row-center {
		text-align: center;
	}
	
	.wyb-table-box,
	.wyb-table-content,
	.wyb-table-scroll-view {
		display: block;
	}

	.family-add-btn {
		width: 60%;
		height: 60rpx;
		font-size: 34rpx;
		margin: 45rpx;
		line-height: 60rpx;
	}

	.popup-add-title {
		width: 100%;
		text-align: center;
		display: block;
		font-size: 40rpx;
		margin: 20rpx 0;
	}

	.iconfont {
		font-size: 36rpx !important;
	}

	.width100 {
		width: 100% !important;
	}

	.reply-btn {
		width: 50%;
		height: 70rpx;
		font-size: 32rpx;
		margin: 15rpx;
	}
</style>
